/*
 * Class PlayerWeapon
 *
 * Version 1.0
 *
 * Saturday, August 23, 2008
 *
 * Created by Palidino76
 */

package palidino76.rs2.player.items;

import palidino76.rs2.Engine;
import palidino76.rs2.player.Player;

public class PlayerWeapon {

    public Player p;

    public PlayerWeapon(Player p) {
        this.p = p;
    }

    public void setWeapon() {
        if (p == null) {
            return;
        }
        p.walkEmote = getWalkEmote(p.equipment[3]);
        p.runEmote = getRunEmote(p.equipment[3]);
        p.standEmote = getStandEmote(p.equipment[3]);
        String weapon = Engine.items.getItemName(p.equipment[3]);
        if (p.equipment[3] == -1) {
            p.frames.setTab(p, 73, 92);
            p.frames.setString(p, weapon, 92, 0);
        } else if (weapon.equals("Abyssal whip")) {
	    p.frames.setInterfaceConfig(p, 93, 10, false);
            p.frames.setTab(p, 73, 93);
            p.frames.setString(p, weapon, 93, 0);
        } else if (weapon.equals("Granite maul") || weapon.equals("Tzhaar-ket-om") || weapon.equals("Torags hammers")) {
            p.frames.setTab(p, 73, 76);
            p.frames.setString(p, weapon, 76, 0);
        } else if (weapon.equals("Veracs flail") || weapon.endsWith("mace")) {
            p.frames.setTab(p, 73, 88);
            p.frames.setString(p, weapon, 88, 0);
        } else if (weapon.endsWith("crossbow") || weapon.endsWith(" c'bow")) {
            p.frames.setTab(p, 73, 79);
            p.frames.setString(p, weapon, 79, 0);
        } else if (weapon.endsWith("bow") || weapon.endsWith("bow full") || weapon.equals("Seercull")) {
            p.frames.setTab(p, 73, 77);
            p.frames.setString(p, weapon, 77, 0);
        } else if (weapon.startsWith("Staff") || weapon.endsWith("staff") || weapon.equals("Toktz-mej-tal")) {
            p.frames.setTab(p, 73, 90);
            p.frames.setString(p, weapon, 90, 0);
        } else if (weapon.endsWith("dart") || weapon.endsWith("knife") || weapon.endsWith("thrownaxe") || weapon.equals("Toktz-xil-ul")) {
            p.frames.setTab(p, 73, 91);
            p.frames.setString(p, weapon, 91, 0);
        } else if (weapon.endsWith("dagger") || weapon.endsWith("dagger(s)") || weapon.endsWith("dagger(+)") || weapon.endsWith("dagger(p)")) {
            p.frames.setTab(p, 73, 89);
            p.frames.setString(p, weapon, 89, 0);
        } else if (weapon.endsWith("pickaxe")) {
            p.frames.setTab(p, 73, 83);
            p.frames.setString(p, weapon, 83, 0);
        } else if (weapon.endsWith("axe") || weapon.endsWith("battleaxe")) {
            p.frames.setTab(p, 73, 75);
            p.frames.setString(p, weapon, 75, 0);
        } else if (weapon.endsWith("halberd")) {
            p.frames.setTab(p, 73, 84);
            p.frames.setString(p, weapon, 84, 0);
        } else if (weapon.endsWith("spear") || weapon.equals("Guthans warspear")) {
            p.frames.setTab(p, 73, 85);
            p.frames.setString(p, weapon, 85, 0);
        } else if (weapon.endsWith("claws")) {
            p.frames.setTab(p, 73, 78);
            p.frames.setString(p, weapon, 78, 0);
        } else if (weapon.endsWith("2h sword") || weapon.endsWith("godsword") || weapon.equals("Saradomin sword")) {
            p.frames.setTab(p, 73, 81);
            p.frames.setString(p, weapon, 81, 0);
        } else {
            p.frames.setTab(p, 73, 82);
            p.frames.setString(p, weapon, 82, 0);
        }
	checkSpecials(p);
    }

    public int getRunEmote(int id) {
        String weapon = Engine.items.getItemName(id);
        if (weapon.endsWith("2h sword") || id == 6528 || weapon.endsWith("godsword") || weapon.equals("Saradomin sword")) {
            return 7039;
        } else if (weapon.equals("Saradomin staff") || weapon.equals("Guthix staff") || weapon.equals("Zamorak staff")) {
            return 0x338;
        } else if (id == 10887) {
            return 5868;
        } else if (id == 4755) {
            return 1831;
        } else if (id == 4734) {
            return 2077;
        } else if (id == 4726 || weapon.contains("Spear") || weapon.endsWith("halberd") || weapon.contains("Staff") || weapon.contains("staff")) {
            return 1210;
        } else if (weapon.equals("Abyssal whip")) {
            return 1661;
        } else if (id == 4153) {
            return 1664;
        }
        return 0x338;
    }

    public int getWalkEmote(int id) {
        String weapon = Engine.items.getItemName(id);
        if(weapon.equals("Saradomin staff") || weapon.equals("Guthix staff") || weapon.equals("Zamorak staff")) {
            return 0x333;
        } else if (id == 10887) {
            return 5867;
        } else if (id == 4718) {
           return 2064;
        } else if (id == 4755) {
           return 2060;
        } else if (id == 4734) {
           return 2076;
        } else if (id == 4153) {
            return 1663;
        } else if (weapon.equals("Abyssal whip")) {
           return 1660;
        } else if (weapon.endsWith("2h sword") || id == 6528 || weapon.endsWith("godsword") || weapon.equals("Saradomin sword")) {
           return 7046;
        } else if (id == 4726 || weapon.contains("spear") || weapon.endsWith("halberd") || weapon.contains("Staff") || weapon.contains("staff")) {
           return 1146;
        }
        return 0x333;
    }

    public int getStandEmote(int id) {
        String weapon = Engine.items.getItemName(id);
        if (id == 4718) {
            return 2065;
        } else if (id == 10887) {
            return 5869;
        } else if (id == 4755) {
            return 2061;
	} else if (p.npcType == 6203) {
	    return 6943;
	} else if (p.npcType == 2745) {
	    return 9274;
        } else if (id == 4734) {
            return 2074;
        } else if (id == 6528 || id == 1319) {
            return 0x811;
        } else if (weapon.equals("Saradomin staff") || weapon.equals("Guthix staff") || weapon.equals("Zamorak staff")) {
            return 0x328;
        } else if (id == 4726 || weapon.endsWith("spear") || weapon.endsWith("halberd") || weapon.contains("Staff") || 
        weapon.contains("staff") || id == 1305) {
            return 809;
        } else if (weapon.endsWith("2h sword") || weapon.endsWith("godsword") || weapon.equals("Saradomin sword")) {
            return 7047;
        } else if (weapon.equals("Abyssal whip")) {
            return 10080;
        } else if (id == 4153) {
            return 1662;
        }
        return 0x328;
    }

	public void checkSpecials(Player p) {
		int weaponId = p.equipment[3];
		/*if (weaponId == 10887) {
			p.frames.setInterfaceConfig(p, 82, 10, false);
		}*/
		if (weaponId == 4151 || weaponId == 10887) {
			p.frames.setInterfaceConfig(p, 93, 10, false);
		} else if (weaponId == 1215 || weaponId == 1231 || weaponId == 5680 || weaponId == 5698 || weaponId == 8872 || weaponId == 8874 || weaponId == 8876 || weaponId == 8878 || weaponId == 10887){
			p.frames.setInterfaceConfig(p, 89, 12, false);
		} else if (weaponId == 35 || weaponId == 1305 || weaponId == 4587 || weaponId == 6746 || weaponId == 11037 || weaponId == 10887){
			p.frames.setInterfaceConfig(p, 82, 12, false);
		} else if (weaponId == 7158 || weaponId == 11694 || weaponId == 11696  || weaponId == 11698 || weaponId == 11700 ||  weaponId == 11730 || weaponId == 10887) {
			p.frames.setInterfaceConfig(p, 81, 12, false);
		} else if (weaponId == 859 || weaponId == 861 || weaponId == 6724|| weaponId == 10284 || weaponId == 859 || weaponId == 11235 || weaponId == 10887){
			p.frames.setInterfaceConfig(p, 77, 13, false);
		} else if (weaponId == 8880 || weaponId == 10887){
			p.frames.setInterfaceConfig(p, 79, 10, false);
		} else if (weaponId == 3101 || weaponId == 10887){
			p.frames.setInterfaceConfig(p, 78, 12, false);
		} else if (weaponId == 10887 || weaponId == 10887) {
			p.frames.setInterfaceConfig(p, 82, 10, false);
		} else if (weaponId == 1434 || weaponId == 11061 || weaponId == 10887){
			p.frames.setInterfaceConfig(p, 88, 12, false);
		} else if (weaponId == 1377 || weaponId == 6739 || weaponId == 10887){
			p.frames.setInterfaceConfig(p, 75, 12, false);
		} else if (weaponId == 4153 || weaponId == 10887){
			p.frames.setInterfaceConfig(p, 76, 10, false);
		} else if (weaponId == 3204 || weaponId == 10887){
			p.frames.setInterfaceConfig(p, 84, 10, false);
		} else {
			//p.frames.setInterfaceConfig(p, 93, 10, true);
		}
	}
}